<template>
  <view class="container p-t-24">

	<view class="boxPanel p-t-26 p-b-26 p-l-30 p-r-30 flex-between radius-20 m-l-24 m-r-24 m-b-24">
      <view class="name">物流公司</view>
      <view class="row-right" style="flex: 1;">
         <input type="text" placeholder="请填写" v-model="formData.refund_delivery_name"  class="inputs" style="text-align: right;">
      </view>
    </view>
    
    <view class="boxPanel p-t-26 p-b-26 p-l-30 p-r-30 flex-between radius-20 m-l-24 m-r-24 m-b-24">
      <view class="name">快递单号</view>
      <view class="row-right" style="flex: 1;">
         <input type="text" placeholder="请填写" v-model="formData.refund_delivery_no"  class="inputs" style="text-align: right;">
      </view>
    </view>
    
     <view class="boxPanel m-l-30 m-r-30 m-b-30">
      <textarea cols="30" rows="5" placeholder="物流说明（选填）" placeholder-class="placeholder" v-model="formData.refund_delivery_remark" maxlength="-1"></textarea>
    </view>
    
    <!-- <view class="boxPanel p-t-26 p-b-26 p-l-30 p-r-30 flex-between radius-20 m-l-24 m-r-24 m-b-24">
      <view class="name">收货人</view>
      <view class="row-right" style="flex: 1;">
         <input type="text" placeholder="请填写" v-model="formData.username"  class="inputs" style="text-align: right;">
      </view>
    </view>
    
    <view class="boxPanel p-t-26 p-b-26 p-l-30 p-r-30 flex-between radius-20 m-l-24 m-r-24 m-b-24">
      <view class="name">联系方式</view>
      <view class="row-right" style="flex: 1;">
         <input type="number" maxlength="11" placeholder="请填写" v-model="formData.mobile"  class="inputs" style="text-align: right;">
      </view>
    </view> -->
    
    <view class="footer fixfooter" :class="{ 'bottom-safe-area': isIphoneX }">
      <view class="submit" @click="submitForm">确定</view>
    </view>
    
  </view>
</template>

<script>
  export default {
    data() {
      return {
        isIphoneX: false, //判断手机是否是iphoneX以上
        order_goods_id: 0,
        formData: {
         	refund_delivery_name: '',
			refund_delivery_no: '',
			refund_delivery_remark: ''
        },
        isSubmitting: false, // 表单提交状态标志
      }
    },
    onLoad(e) {
      this.isIphoneX = this.$util.uniappIsIPhoneX()
      this.order_goods_id = e.order_goods_id || 0;

    },
    methods: {
      validateForm() {
        const { refund_delivery_name, refund_delivery_no} = this.formData;

		if (!refund_delivery_name) {
          this.$util.showToast({ title: '请填写物流公司' });
          return false;
        }

        if (!refund_delivery_no) {
          this.$util.showToast({ title: '请填写快递单号' });
          return false;
        }
       
        return true;
      },
       submitForm() {
          if (this.isSubmitting || !this.validateForm()) {
            return; 
          }
          this.isSubmitting = true;

          this.$api.sendRequest({
            url: '/api/orderrefund/delivery', 
            data: {
              order_goods_id: this.order_goods_id,
              ...this.formData
            },
            success: (res) => {
              this.isSubmitting = false; 
              if (res.code == 0) {
                this.$util.showToast({ title: '提交成功' });
                setTimeout(() => {
					this.$util.redirectTo('/pages/mallOrder/mallOrder',{},'reLaunch');
				}, 1000);
              } else {
                this.$util.showToast({ title: res.message });
              }
            }
          });
        
      },
    }
  }
</script>

<style lang="scss" scoped>
.row-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
textarea {
    height: 300rpx;
  }
</style
</style>
